//
//  SXTAFNetworkingClient.m
//  
//
//  Created by ma c on 16/8/20.
//
//

#import "SXTAFNetworkingClient.h"

@implementation SXTAFNetworkingClient

+(instancetype)shareClient{

    static SXTAFNetworkingClient * manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[SXTAFNetworkingClient alloc]initWithBaseURL:[NSURL URLWithString:@"http://123.57.141.249:8080/beautalk/"]];
        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", nil];
    });
    return manager;
}



+ (void)POSTRequest:(NSString * )url
              param:(NSDictionary *)param
          isSuccess:(requestErrorBlock)returnSuccess
            isError:(requestErrorBlock)returnError{

  [[SXTAFNetworkingClient shareClient] POST:url parameters:param progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
      if (returnSuccess) {
          returnSuccess(responseObject);
      }
  } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
      if (returnError) {
          returnError(error);
      }
  }];

}

+(void)GETRequest:(NSString *)url param:(NSDictionary *)param isSuccess:(requestErrorBlock)returnSuccess isError:(requestErrorBlock)returnError{

   [[SXTAFNetworkingClient shareClient] GET:url parameters:param progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
       if (returnSuccess) {
           returnSuccess(responseObject);
       }
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       if (returnError) {
           returnError(error);
       }
   }];

}













@end
